/**
 * @filename:RolesController 2022-03-22 02:40:48
 * @project com/lwl/blue  V1.0
 * Copyright(c) 2020 <a href=mailto:lanwenliang@yidianlife.com>蓝文良</a> Co. Ltd.
 * All right reserved.
 */
package com.lwl.blue.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lwl.blue.commont.base.*;
import com.lwl.blue.commont.utils.MD5Utils;
import com.lwl.blue.entity.Roles;
import com.lwl.blue.entity.Roles;
import com.lwl.blue.service.RolesService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>自定义方法写在这里</p>
 *
 * <p>说明： 角色API接口层</P>
 * @version: V1.0
 * @author: <a href=mailto:lanwenliang@yidianlife.com>蓝文良</a>
 *
 */
@Api(tags = "角色")
@RestController
@RequestMapping("/roles")
@Slf4j
public class RolesController extends BaseController {
    @Autowired
    RolesService rolesService;

    @PostMapping("/pages")
    public PageResult<Roles> getPages(@RequestBody PageParam<Roles> pageParam) {
        JsonResult<Page<Roles>> pages = rolesService.pages(pageParam);
        PageResult<Roles> re = new PageResult<>();
        re.success(pages.getData().getTotal(), pages.getData().getRecords());
        return re;
    }

    @PostMapping("saveOrUpdate")
    public JsonResult saveOrUpdate(@RequestBody Roles roles) {
        setInsetOrUpdateUser(roles);
        rolesService.saveOrUpdate(roles);
        return new JsonResult().success("请求成功");
    }

    @PostMapping("/delete/{id}")
    public JsonResult saveOrUpdate(@PathVariable(value = "id") Integer id) {
        rolesService.removeById(id);
        return new JsonResult().success("请求成功");
    }
}
